<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title>新增页面</title>
		<link href="../../static/component/pear/css/pear.css" rel="stylesheet" th:href="@{/static/component/pear/css/pear.css}"/>
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">
					<div class="layui-form-item">
						<label class="layui-form-label"><span style="color: red">原密码</span></label>
						<div class="layui-input-block">
							<input type="text" name="oldpwd" lay-verify="title" autocomplete="off" placeholder="请输入原密码"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label"><span style="color: red">新密码</span></label>
						<div class="layui-input-block">
							<input type="text" name="newpwd" lay-verify="title" autocomplete="off" placeholder="请输入新密码"
								   class="layui-input">
						</div>
					</div>
				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					提示：红色必填
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="user-save">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="../../static/component/layui/layui.js" th:src="@{/static/component/layui/layui.js}"></script>
		<script src="../../static/component/pear/pear.js" th:src="@{/static/component/pear/pear.js}"></script>
		<script>
			layui.use(['form', 'jquery'], function() {
				let form = layui.form;
				let $ = layui.jquery;

				form.on('submit(user-save)', function(data) {
					$.ajax({
						// url: '/add',
						url: '/admin/index/changpwd',
						data: JSON.stringify(data.field),
						dataType: 'json',
						contentType: 'application/json',
						type: 'post',
						success: function(result) {
							if (result.code === 0) {
								layer.msg(result.msg, {
									icon: 1,
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									// parent.layui.table.reload("user-table");
								});
							} else {
								layer.msg(result.msg, {
									icon: 2,
									time: 1000
								});
							}
						},
						error:function () {
							layer.alert("网络错误")
						}
					})
					return false;
				});
			})
		</script>
		<script>
		</script>
	</body>
</html>
